﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace Morro.VPN.Desktop.DataDisplay
{
    public class ViewPlotter : Panel
    {




        private Size CalculateMaxSize(Size availableSize)
        {
            double maxDimension = Math.Min(availableSize.Height,
                                            availableSize.Width);

            Size maxSize = new Size(maxDimension, maxDimension);

            return maxSize;
        }

        protected override Size MeasureOverride(Size availableSize)
        {
            Size maxSize = CalculateMaxSize(availableSize);

            foreach (UIElement uiElement in Children)
            {
                uiElement.Measure(maxSize);
            }

            return maxSize;
        }

        protected override Size ArrangeOverride(Size finalSize)
        {
            Size maxSize = CalculateMaxSize(finalSize);


            foreach (UIElement child in Children)
            {
                child.Arrange(new Rect(new Point(0, 0), maxSize));
            }

            return maxSize;
        }


    }
}
